function [der]=deryy(coor,data,n_nodes)
%% Finite Different Scheme
% This program is used to calculate the second (second
% order) derive of the discret coor

for i=1:n_nodes        
    if (i<round(n_nodes/2))
        hp1=coor(i+1)-coor(i);
        hp2=coor(i+2)-coor(i);
        if (i==1)
            hp3=coor(i+3)-coor(i);
            n2=-2*(hp2+hp3)/(-hp2*hp1+hp2*hp3+hp1*hp1-hp3*hp1)/hp1;
            p2=2*(hp1+hp3)/(-hp3*hp1+hp2*hp1-hp2*hp2+hp2*hp3)/hp2;
            q2=-2*(hp1+hp2)/(-hp3*hp1+hp2*hp1+hp3*hp3-hp2*hp3)/hp3;
            s2=-(n2+p2+q2);
            der(i,1)=s2*data(i)+n2*data(i+1)+p2*data(i+2)+q2*data(i+3);            
        else
            hm1=coor(i-1)-coor(i);
            m2=-2*(hp1+hp2)/(hp1*hp2-hm1*hp1+hm1*hm1-hm1*hp2)/hm1;
            n2=-2*(hm1+hp2)/(-hp1*hm1+hm1*hp2+hp1*hp1-hp1*hp2)/hp1;
            p2=2*(hp1+hm1)/(hp1*hp2-hm1*hp1-hp2*hp2+hm1*hp2)/hp2;
            s2=-(m2+n2+p2);
            der(i,1)=m2*data(i-1)+s2*data(i)+n2*data(i+1)+p2*data(i+2);
        end
    else
        hm1=coor(i-1)-coor(i);
        hm2=coor(i-2)-coor(i);        
        if (i==n_nodes)
            hm3=coor(i-3)-coor(i);  
            m2=-2*(hm2+hm3)/(-hm2*hm1+hm2*hm3+hm1*hm1-hm3*hm1)/hm1;
            p2=2*(hm1+hm3)/(-hm3*hm1+hm2*hm1-hm2*hm2+hm2*hm3)/hm2;
            q2=-2*(hm1+hm2)/(-hm3*hm1+hm2*hm1+hm3*hm3-hm2*hm3)/hm3;
            s2=-(m2+p2+q2);
            der(i,1)=s2*data(i)+m2*data(i-1)+p2*data(i-2)+q2*data(i-3);            
        else
            hp1=coor(i+1)-coor(i);
            m2=-2*(hp1+hm2)/(hp1*hm2-hm1*hp1+hm1*hm1-hm1*hm2)/hm1;
            n2=-2*(hm1+hm2)/(-hp1*hm1+hm1*hm2+hp1*hp1-hp1*hm2)/hp1;
            p2=2*(hp1+hm1)/(hp1*hm2-hm1*hp1-hm2*hm2+hm1*hm2)/hm2;
            s2=-(m2+n2+p2);
            der(i,1)=m2*data(i-1)+s2*data(i)+n2*data(i+1)+p2*data(i-2);
        end        
    end
        
end
